<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <button>按钮</button>

  <input type="text">

  <script>
    function hythrottle(fn, interval) {
      let startTime = 0

      const _throttle = function (...args) {
        const nowTime = new Date().getTime()
        const waitTime = interval - (nowTime - startTime)
        if (waitTime <= 0) {
          fn.apply(this, args)
          startTime = nowTime
        }
      }

      return _throttle
    }
  </script>

  <script>
    // 1.获取input元素
    const inputEl = document.querySelector("input")

    // 2.节流处理代码
    let counter = 1
    inputEl.oninput = hythrottle(function () {
      console.log(`发送网络请求${counter++}:`, this.value, event)
    }, 1000)

  </script>

</body>

</html>